import { loginGetToken } from '@/api/login'
import { LoginValues } from '@/types/data'
import { RootThunkAction } from '@/types/store'
import { setToken } from '@/utils/storage'

export const login = (data:LoginValues):RootThunkAction => {
  return async dispatch => {
    const res = await loginGetToken(data)
    setToken(res.data)
    dispatch({
      type: 'login/Token',
      payload: res.data
    })
  }
}
